package com.xneure.database.dialect;

import java.util.Date;
import com.xneure.utils.DateUtil;
import com.xneure.utils.StrUtil;

public class MySqlDialect extends SqlDialect{
	public MySqlDialect(){
	}

	@Override
	public String joint(String... str){
		return "CONCAT(".concat(StrUtil.join(str,",")).concat("");
	}

	@Override
	public String paging(String sql,int start,int end){
		return sql.concat(String.format(" limit %1s,%2s  ",start,end));
	}

	@Override
	public String toDate(Object _value){
		return "STR_TO_DATE('" + DateUtil.dateFormat((Date)_value) + "','%Y/%m/%d %H:%i:%s')";
	}

	@Override
	public String toTimestamp(Object _value){
		return DateUtil.dateFormat((Date)_value,DateUtil.DEFAULT_TIMESTAMP_FORMAT);
	}
}
